package com.jack.helloworld.activity;

import android.app.WallpaperManager;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.jack.helloworld.MediaRecorder.MediaRecorderActivity;
import com.jack.helloworld.R;
import com.jack.helloworld.activity.mode.BaseActivity;
import com.jack.helloworld.liveWallpaper.LiveWallpaperPreview;
import com.jack.helloworld.liveWallpaper.VideoLiveWallPaperLoaderActivity;

import java.io.IOException;

public class Main06Activity extends BaseActivity implements View.OnClickListener {
    
    Button btnCalculator;
    Button btnGradView;
    Button btnSpinner;
    Button btnSimpleSpinner;
    Button btnProgressBar;
    Button btnUri;
    Button btnWebView;
    Button btnFragment;
    Button btnFragmentValue;
    Button btnViewPager;
    Button btnFragmentViewPager;
    Button btnViewFlipper;
    Button btnScrollView;
    Button btnGallery;
    Button btnSeekBar;
    Button btnImageLoader;
    Button btnAudioRecorder;
    Button btnLiveWallpaper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main06);
    
        initView();
        initData();
    }
    
    protected void initView() {
        
        btnCalculator = (Button) findViewById(R.id.btnCalculator);
        btnGradView = (Button) findViewById(R.id.btnGradView);
        btnSpinner = (Button) findViewById(R.id.btnSpinner);
        btnSimpleSpinner = (Button) findViewById(R.id.btnSimpleSpinner);
        btnProgressBar = (Button) findViewById(R.id.btnProgressBar);
        btnUri = (Button) findViewById(R.id.btnUri);
        btnWebView = (Button) findViewById(R.id.btnWebView);
        btnFragment = (Button) findViewById(R.id.btnFragment);
        btnFragmentValue = (Button) findViewById(R.id.btnFragmentValue);
        btnViewPager = (Button) findViewById(R.id.btnViewPager);
        btnFragmentViewPager = (Button) findViewById(R.id.btnFragmentViewPager);
        btnViewFlipper = (Button) findViewById(R.id.btnViewFlipper);
        btnScrollView = (Button) findViewById(R.id.btnScrollView);
        btnGallery = (Button) findViewById(R.id.btnGallery);
        btnSeekBar = (Button) findViewById(R.id.btnSeekBar);
        btnImageLoader = (Button) findViewById(R.id.btnImageLoader);
        btnAudioRecorder = (Button) findViewById(R.id.btnAudioRecorder);
        btnLiveWallpaper = (Button) findViewById(R.id.btnLiveWallpaper);
    }
    
    protected void initData() {
        
        btnCalculator.setOnClickListener(this);
        btnGradView.setOnClickListener(this);
        btnSpinner.setOnClickListener(this);
        btnSimpleSpinner.setOnClickListener(this);
        btnProgressBar.setOnClickListener(this);
        btnUri.setOnClickListener(this);
        btnWebView.setOnClickListener(this);
        btnFragment.setOnClickListener(this);
        btnFragmentValue.setOnClickListener(this);
        btnViewPager.setOnClickListener(this);
        btnFragmentViewPager.setOnClickListener(this);
        btnViewFlipper.setOnClickListener(this);
        btnScrollView.setOnClickListener(this);
        btnGallery.setOnClickListener(this);
        btnSeekBar.setOnClickListener(this);
        btnImageLoader.setOnClickListener(this);
        btnAudioRecorder.setOnClickListener(this);
        btnLiveWallpaper.setOnClickListener(this);
        
    }
    
    
    @Override
    public void onClick(View view) {
        switch (view.getId()) {

            case R.id.btnCalculator:
                Intent intent = new Intent(this, CalculaterActivity.class);
                startActivity(intent);
                break;
            case R.id.btnGradView:
                intent = new Intent(this, GridViewActivity.class);
                startActivity(intent);
                break;
            case R.id.btnSpinner:
                intent = new Intent(this, SpinnerActivity.class);
                startActivity(intent);
                break;
            case R.id.btnSimpleSpinner:
                intent = new Intent(this, SimpleSpinnerActivity.class);
                startActivity(intent);
                break;
            case R.id.btnProgressBar:
                intent = new Intent(this, ProgressBarActivity.class);
                startActivity(intent);
                break;
            case R.id.btnUri:
                intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.baidu.com"));
                startActivity(intent);
                break;
            case R.id.btnWebView:
                intent = new Intent(this, WebViewActivity.class);
                startActivity(intent);
                break;
            case R.id.btnFragment:
                intent = new Intent(this, FragmentMainActivity.class);
                startActivity(intent);
                break;
            case R.id.btnFragmentValue:
                intent = new Intent(this, FragmentValueActivity.class);
                startActivity(intent);
                break;
            case R.id.btnViewPager:
                intent = new Intent(this, ViewPagerActivity.class);
                startActivity(intent);
                break;
            case R.id.btnFragmentViewPager:
                intent = new Intent(this, FragmentViewPagerActivity.class);
                startActivity(intent);
                break;
            case R.id.btnViewFlipper:
                intent = new Intent(this, ViewFlipperActivity.class);
                startActivity(intent);
                break;
            case R.id.btnScrollView:
                intent = new Intent(this, ScrollViewActivity.class);
                startActivity(intent);
                break;
            case R.id.btnGallery:
                intent = new Intent(this, GalleryActivity.class);
                startActivity(intent);
                break;
            case R.id.btnSeekBar:
                intent = new Intent(this, SeekBarActivity.class);
                startActivity(intent);
                break;
            case R.id.btnImageLoader:
                intent = new Intent(this, ImageLoaderActivity.class);
                startActivity(intent);
                break;
            
            case R.id.btnAudioRecorder:
                intent = new Intent(this, AudioRecorderActivity.class);
                startActivity(intent);
                break;
            
            case R.id.btnLiveWallpaper:
                intent = new Intent(this, LiveWallpaperPreview.class);
                startActivity(intent);
                break;
        }
        
    }
    
    public void doClick(View view) {
        Intent intent;
        switch (view.getId()) {
            case R.id.btnDefaultWallpaper:
                try {
                    WallpaperManager.getInstance(this).clear();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                break;
            
            case R.id.btnLiveWallpaperVideoLoader:
                intent = new Intent(this, VideoLiveWallPaperLoaderActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
                break;
            
            case R.id.btnMediaPlayer:
                intent = new Intent(this, MediaPlayerActivity.class);
                startActivity(intent);
                break;
            
            case R.id.btnMediaRecorder:
                intent = new Intent(this, MediaRecorderActivity.class);
                startActivity(intent);
                break;
            
        }
    }
}
